//
//  QDAboutController.m
//  QuickDoctor
//
//  Created by ycw on 2016/12/21.
//  Copyright © 2016年 Eric. All rights reserved.
//

#import "QDAboutController.h"

@interface QDAboutController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation QDAboutController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.title = @"关于产品";
    
    [self setUpUI];
}

#pragma mark
#pragma mark - 搭建界面
- (void) setUpUI
{
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStyleGrouped];
    
    [self.view addSubview:tableView];
    
    tableView.delegate = self;
    
    tableView.dataSource = self;
    
    tableView.scrollEnabled = NO;
    
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"aboutCell"];
    
    tableView.tableHeaderView = [self createHeaderView];
    
    tableView.tableFooterView = [self createFooterView];
    
}

#pragma mark
#pragma mark - 实现数据源方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 1;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"aboutCell" forIndexPath:indexPath];
    
    cell.imageView.image = [UIImage imageNamed:@"product_img_icon_xieyi.png"];
    
    cell.textLabel.text = @"用户协议";
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
    
}

#pragma mark
#pragma mark - 自定义表头视图

- (UIView *)createHeaderView
{
    
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 200)];
    
    headerView.backgroundColor = [UIColor whiteColor];
    
    UIImageView *imgV = [[UIImageView alloc] init];
    
    [headerView addSubview:imgV];
    
    imgV.image = [UIImage imageNamed:@"product_img_logo_nor.png"];
    
    [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(headerView).mas_offset(-10);
        
        make.centerX.equalTo(headerView);
        
        make.height.mas_equalTo(80);
        
        make.width.mas_equalTo(60);
        
    }];
    
    UIImageView *imgTitle = [[UIImageView alloc] init];
    
    [headerView addSubview:imgTitle];
    
    imgTitle.image = [UIImage imageNamed:@"product_text_logo_nor.png"];
    
    [imgTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(imgV.mas_bottom);
        
        make.height.mas_equalTo(40);
        
        make.width.mas_equalTo(60);
        
        make.leading.equalTo(imgV);
        
    }];
    
    
    return headerView;
    
}

#pragma mark
#pragma mark - 自定义表尾视图

- (UIView *)createFooterView
{
    
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 400, [UIScreen mainScreen].bounds.size.width, 350)];
    
    footerView.backgroundColor = [UIColor whiteColor];
    
    UILabel *lblBottom = [[UILabel alloc] init];
    
    lblBottom.text = @"version: 1.4.0";
    
    lblBottom.textColor = [UIColor colorWithRed:74/255.0 green:182/255.0 blue:243/255.0 alpha:1];
    
    lblBottom.textAlignment = NSTextAlignmentCenter;
    
    lblBottom.font = [UIFont systemFontOfSize:15];
    
    [footerView addSubview:lblBottom];
    
    [lblBottom mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.trailing.equalTo(footerView);
        
        make.height.mas_equalTo(30);
        
        make.bottom.equalTo(footerView).mas_offset(-80);
        
    }];
    
    UILabel *lblTop = [[UILabel alloc] init];
    
    lblTop.text = @"用户交流群: 4638375473";
    
    lblTop.textColor = [UIColor colorWithRed:74/255.0 green:182/255.0 blue:243/255.0 alpha:1];
    
    lblTop.textAlignment = NSTextAlignmentCenter;
    
    lblTop.font = [UIFont systemFontOfSize:15];
    
    [footerView addSubview:lblTop];
    
    [lblTop mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.trailing.equalTo(footerView);
        
        make.height.mas_equalTo(50);
        
        make.bottom.equalTo(lblBottom.mas_top);
        
    }];
    
    
    
    return footerView;
    
}




@end
